package com.enba.boot.mq.factory;

import com.enba.boot.mq.MessageSenderStrategy;
import java.util.List;

public class MqStrategyFactory {

  private final List<MessageSenderStrategy> messageSenderStrategyList;

  public MqStrategyFactory(List<MessageSenderStrategy> messageSenderStrategyList) {
    this.messageSenderStrategyList = messageSenderStrategyList;
  }

  public MessageSenderStrategy getMessageSenderStrategy(String strategyKey) {
    for (MessageSenderStrategy messageSenderStrategy : messageSenderStrategyList) {
      if (messageSenderStrategy.getStrategyKey().equals(strategyKey)) {
        return messageSenderStrategy;
      }
    }
    throw new UnsupportedOperationException("不支持的消息发送渠道: " + strategyKey);
  }
}
